package sgbag1.Vues;

import java.awt.Color;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;

import java.awt.RenderingHints;
import java.awt.geom.Point2D;

import sgbag1.Noyau.Guichet;

public class VueGuichet extends VueElement {
    
    private int dimension = 30;
    private Color couleur = new Color(255, 0, 0);
    private Guichet guichet;
    
    public VueGuichet(Guichet g){
        super(new Point(g.getPosition()));
        guichet = g;
        this.CalculerBoiteEnglobante();
    }
    
    public Guichet getObjetNoyau(){
        return guichet;
    }
    
    @Override
    public void setTauxConversion(double t){
        super.setTauxConversion(t);
        position = new Point(guichet.getPosition());
        position.x *= tauxConversion;
        position.y *= tauxConversion;
        //position.setLocation(position.getX() * tauxConversion, position.getY()*tauxConversion);

        this.CalculerBoiteEnglobante();
    }
    
    @Override
    public void setDecalage(Point p){
        super.setDecalage(p);
        
        position.translate(decalage.x, decalage.y);
        this.CalculerBoiteEnglobante();
    }
    
    @Override
    public void Dessiner(Graphics g){
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        
        g2.setColor(couleur);
        g2.fill(boiteEnglobante);
        g2.setColor(new Color(0,0,0));
        g2.drawString("" + guichet.getId(), position.x - dimension/2, position.y);
        super.Dessiner(g);
    }
    
    @Override
    public void CalculerBoiteEnglobante() {
        boiteEnglobante = new Rectangle(position.x - dimension, position.y - dimension/2, dimension, dimension);
    }
}
